package com.fr.chart.marker;

import com.fr.base.XMLable;
import com.fr.base.core.json.JSONException;
import com.fr.base.core.json.JSONObject;
import com.fr.base.xml.XMLPrintWriter;
import com.fr.base.xml.XMLableReader;
import com.fr.chart.core.ChartUtils;
import java.awt.Color;
import java.awt.Graphics2D;
import java.awt.Paint;

public abstract class Marker
  implements XMLable
{
  private static final long serialVersionUID = 6913605407851388493L;
  public static final String XML_TAG = "Marker";
  protected double size = 5.0D;
  protected Color color;

  public double getSize()
  {
    return this.size;
  }

  public void setSize(double paramDouble)
  {
    this.size = paramDouble;
  }

  public void setColor(Color paramColor)
  {
    this.color = paramColor;
  }

  public Color getColor()
  {
    return this.color;
  }

  public void paint(Graphics2D paramGraphics2D, double paramDouble1, double paramDouble2)
  {
    Paint localPaint = paramGraphics2D.getPaint();
    if (this.color != null)
      paramGraphics2D.setPaint(this.color);
    paintMarker(paramGraphics2D, paramDouble1, paramDouble2);
    paramGraphics2D.setPaint(localPaint);
  }

  protected abstract void paintMarker(Graphics2D paramGraphics2D, double paramDouble1, double paramDouble2);

  public void readXML(XMLableReader paramXMLableReader)
  {
    if ((paramXMLableReader.isChildNode()) && ("Style".equals(paramXMLableReader.getTagName())))
    {
      String str;
      if ((str = paramXMLableReader.getAttr("size")) != null)
        this.size = Double.parseDouble(str);
      if ((str = paramXMLableReader.getAttr("color")) != null)
        this.color = new Color(Integer.parseInt(str), true);
    }
  }

  public void writeXML(XMLPrintWriter paramXMLPrintWriter)
  {
    paramXMLPrintWriter.startTAG("Marker");
    paramXMLPrintWriter.startTAG("Style").attr("size", this.size);
    if (this.color != null)
      paramXMLPrintWriter.attr("color", this.color.getRGB());
    paramXMLPrintWriter.end();
    paramXMLPrintWriter.end();
  }

  public boolean equals(Object paramObject)
  {
    return super.getClass().isInstance(paramObject);
  }

  public Object clone()
    throws CloneNotSupportedException
  {
    return super.clone();
  }

  public JSONObject toJSONObject()
    throws JSONException
  {
    JSONObject localJSONObject = new JSONObject();
    localJSONObject.put("size", this.size);
    localJSONObject.put("color", ChartUtils.color2JS(this.color));
    return localJSONObject;
  }

  public abstract String getMarkerType();
}